﻿@*
    For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
*@
@{
    ViewBag.Title = "考试管理";
    Exam exam = ViewBag.exam;
}

<div>
    <a href="@Url.Action("ExamLib")" class="layui-btn">考试库</a>
</div>
<div>
    <input id="txtID" type="hidden" value="@exam.ID" />
    考试名称：<input id="txtName" type="text" value="@exam.Name" />
</div>
<div>
    <button class="layui-btn" onclick="save();">保存</button>
</div>

@section script{
    <script>
        function save() {
            let obj = new Object();
            obj.ID = $("#txtID").val();
            obj.Name = $("#txtName").val();
            layer.msg("正在保存，请稍候...", {
                icon: 16,
                time: 0,
                shade: 0.3,
                shadeClose: false
            });
            $.ajax({
                type: "POST",
                url: "@Url.Action("ExamSave")",
                data: obj,
                success: function (result) {
                    layer.msg(result.msg);
                    if (result.success) {
                        $("#txtID").val(result.data.exam.ID);
                        $("#txtName").val(result.data.exam.Name);
                    }
                }
            });
        }
    </script>
}